Skip to main content

AudioSource Class

Description:

  A record for creating AudioSource nodes.

__call

Type: Metamethod.

Description:

  Creates a new AudioSource node.

Signature:

metamethod __call: function(self: AudioSourceClass, filename: string, autoRemove?: boolean, bus?: AudioBus): AudioSource | nil

Parameters:

ParameterTypeDescription
filenamestringThe path to the audio file.
autoRemoveboolean[optional] Whether the audio source should be removed when it's stopped. Default is true.
busAudioBus[optional] The bus to play the audio source on. Default is nil.

Returns:

Return TypeDescription
AudioSource | nilThe created AudioSource node. If the audio file is not loaded, it will return nil.